﻿using Comkarl.Web;
using Comkarl.Web.Resources;
using Comkarl.Web.UI.Controls;
using System;

namespace Comkarl.Calipso.Web.SampleClient.Controls
{
    public sealed class OSInfo : ScriptControl
    {
        protected override string CommonID
        {
            get
            {
                return "OSInfo";
            }
        }

        protected override string ControlElementCssClass
        {
            get
            {
                return "OSInfoContainer";
            }
        }

        public string OSName
        {
            get
            {
                return Environment.OSVersion.VersionString;
            }
        }

        protected override void AddClientProperties()
        {
            base.AddClientProperties();

            ClientProperties.Add
            (
                new ClientProperty
                {
                    Id = Guid.Parse("bb8ba24d-6d8a-4386-a98d-857758c6ed5c"),
                    Name = "OSName",
                    Value = OSName
                }
            );
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            JavaScriptManager.RegisterInclude
            (
                "Classes//UI/Controls/OSInfo",
                "Comkarl.Calipso.Web.SampleClient.Controls.OSInfo.ScriptControl.js, Comkarl.Calipso.Web.SampleClient",
                ResourceKind.Resource
            );

            JavaScriptManager.RegisterReference("Classes//UI/Controls/OSInfo");
        }
    }
}